{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from typing import List\n",
    "from collections import Counter\n",
    "class Solution:\n",
    "    def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:\n",
    "        result = [[]]\n",
    "        candidate = []\n",
    "        c = Counter(nums)\n",
    "        for k,cnt in c.items():\n",
    "            candidate.append([[k]*i for i in range(1,cnt+1)])\n",
    "        for i in candidate:\n",
    "            result = result + [ x+j for x in result for j in i]\n",
    "        return result\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[]]\n"
     ]
    }
   ],
   "source": [
    "a = Solution()\n",
    "nums = [1,2,2,2]\n",
    "nums = []\n",
    "print(a.subsetsWithDup(nums))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
